#pragma once
#include "MessagePump.h"

namespace xBase
{
    class CxMessagePumpForUI : public CxMessagePump
    {
    public:
        static const int kMessageFilterCode = 0x5001;

        CxMessagePumpForUI();
        virtual ~CxMessagePumpForUI();

        virtual VOID ScheduleWork();

        virtual VOID ScheduleDelayedWork(const xBase::CTime& oDelayedWorkTime);

        VOID PumpOutPendingPaintMessages();

        BOOL AddMsgFilter(CxMessageFilter* pFilter);
        BOOL RemoveMsgFilter(CxMessageFilter* pFilter);

        BOOL ProcessMessage(const MSG& msg);

    private:
        static LRESULT CALLBACK WndProcThunk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

        virtual VOID DoRunLoop();

        VOID InitMessageWnd();

        VOID WaitForWork();

        VOID HandleWorkMessage();

        VOID HandleTimerMessage();

        BOOL ProcessNextWindowsMessage();

        BOOL ProcessMessageHelper(const MSG& msg);

        BOOL ProcessPumpReplacementMessage();

        BOOL PreTranslateMessage(const MSG* pMsg);

    private:
        HWND                            m_hMsgWnd;
        std::list<CxMessageFilter*>     m_ltMsgFilter;
    };
}